home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frmSprite2
- BorderStyle = 1 'Fixed Single
- Caption = "The Sprite2 Program"
- ClientHeight = 3930
- ClientLeft = 1320
- ClientTop = 1725
- ClientWidth = 4755
- Height = 4620
- Icon = "SPRITE2.frx":0000
- Left = 1260
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 262
- ScaleMode = 3 'Pixel
- ScaleWidth = 317
- Top = 1095
- Width = 4875
- Begin VB.Timer Timer1
- Interval = 50
- Left = 3480
- Top = 2400
- End
- Begin TegommLibCtl.Tegomm Tegomm1
- Height = 495
- Left = 600
- TabIndex = 0
- Top = 120
- Width = 3510
- _version = 65536
- _extentx = 6191
- _extenty = 873
- _stockprops = 64
- End
- Begin TegsprLibCtl.TegoSprite sprBus
- Left = 960
- Top = 2040
- _version = 65536
- _extentx = 4260
- _extenty = 2990
- _stockprops = 0
- spritefilename = "c:\ocxprog\programs\ch06\bus0.bmp"
- maskfilename = "c:\ocxprog\programs\ch06\Mbus0.bmp"
- spriteleft = 64
- spritetop = 136
- spriteheight = 113
- spritewidth = 161
- End
- Begin TegsprLibCtl.TegoSprite sprBack
- Left = 0
- Top = 0
- _version = 65536
- _extentx = 11165
- _extenty = 6985
- _stockprops = 0
- spritefilename = "c:\ocxprog\programs\ch06\road.bmp"
- maskfilename = "c:\ocxprog\programs\ch06\Mroad.bmp"
- spriteheight = 264
- spritewidth = 422
- transparent = 0 'False
- autosize = -1 'True
- End
- Begin VB.Menu mnuFile
- Caption = "&File"
- Begin VB.Menu mnuExit
- Caption = "E&xit"
- End
- End
- Begin VB.Menu mnuEffects
- Caption = "&Effects"
- Begin VB.Menu mnuSound
- Caption = "&Sound"
- End
- Begin VB.Menu mnuBumpyRide
- Caption = "&Bumpy Ride"
- End
- End
- Begin VB.Menu mnuHelp
- Caption = "&Help"
- Begin VB.Menu mnuAbout
- Caption = "&About..."
- End
- End
- Attribute VB_Name = "frmSprite2"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- ' All variables must be declared.
- Option Explicit
- ' Declare handles for the show's sprites.
- Dim gBack As Long
- Dim gBus0 As Long
- Dim gBus1 As Long
- Dim gBus2 As Long
- Dim gBus3 As Long
- Private Sub Form_Load()
- Dim Path
- ' Get the name of the directory where the
- ' program resides.
- Path = App.Path
- If Right(Path, 1) <> "\" Then
- Path = Path + "\"
- End If
- ' Open a WAV file for background music.
- Tegomm1.Visible = False
- Tegomm1.DeviceType = "WaveAudio"
- Tegomm1.filename = Path + "BUS.WAV"
- Tegomm1.Command = "Open"
- ' Initialize all the sprite controls.
- sprBack.InitializeSprite Me.hWnd
- sprBus.InitializeSprite Me.hWnd
-
- ' Open all the sprites that will be used in our show.
- gBack = sprBack.OpenSprite(Path + "ROAD.BMP")
- gBus0 = sprBack.OpenSprite(Path + "BUS0.BMP")
- gBus1 = sprBack.OpenSprite(Path + "BUS1.BMP")
- gBus2 = sprBack.OpenSprite(Path + "BUS2.BMP")
- gBus3 = sprBack.OpenSprite(Path + "BUS3.BMP")
- End Sub
- Private Sub Form_Paint()
- ' Draw the sprBack sprite inside WinG
- sprBack.SpriteHandle = gBack
- sprBack.DrawSprite
- ' Draw the sprBus sprite inside WinG.
- sprBus.SpriteHandle = gBus0
- sprBus.DrawSprite
- ' Slam WinG into the screen
- sprBack.SlamIt
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- ' Close all the sprites of the show.
- sprBack.CloseSprite (gBack)
- sprBack.CloseSprite (gBus0)
- sprBack.CloseSprite (gBus1)
- sprBack.CloseSprite (gBus2)
- sprBack.CloseSprite (gBus3)
- End Sub
- Private Sub mnuAbout_Click()
- Dim Title
- Dim Msg
- Dim CR
- CR = Chr(13) + Chr(10)
- ' Prepare the title of the About message box.
- Title = "About the Sprite2 Program"
- Msg = "This program was written with Visual "
- Msg = Msg + "Basic for Windows, using the "
- Msg = Msg + "TegoSoft Sprite OCX control. "
- Msg = Msg + CR + CR
- Msg = Msg + "The TegoSoft Sprite OCX control "
- Msg = Msg + "is part of the TegoSoft OCX Control "
- Msg = Msg + "Kit - a collection of various OCX controls. "
- Msg = Msg + CR + CR
- Msg = Msg + "For more information about the "
- Msg = Msg + "TegoSoft OCX Control Kit, contact TegoSoft "
- Msg = Msg + "at:"
- Msg = Msg + CR + CR
- Msg = Msg + "TegoSoft Inc." + CR
- Msg = Msg + "P.O. Box 389" + CR
- Msg = Msg + "Bellmore, NY 11710"
- Msg = Msg + CR + CR
- Msg = Msg + "Phone: (516)783-4824"
- ' Display the About message box.
- MsgBox Msg, vbInformation, Title
- ' If the Sound menu item is checked,
- ' make sure that there is playback after
- ' the user closes the modal message box.
- If mnuSound.Checked Then
- Tegomm1.Command = "Play"
- End If
- End Sub
- Private Sub mnuBumpyRide_Click()
- ' Toggle the check mark of the Bumpy Ride menu item.
- mnuBumpyRide.Checked = Not mnuBumpyRide.Checked
- End Sub
- Private Sub mnuExit_Click()
- ' Terminate the program.
- Unload Me
- End Sub
- Private Sub mnuSound_Click()
- ' Toggle the check mark of the Sound menu item.
- mnuSound.Checked = Not mnuSound.Checked
- ' If the Sound menu item is checked, play the
- ' WAV file. Otherwise, stop playing the WAV file.
- If mnuSound.Checked Then
- Tegomm1.Command = "Play"
- Else
- Tegomm1.Command = "Stop"
- End If
- End Sub
- Private Sub Tegomm1_Done()
- ' If the Sound menu item is not checked,
- ' terminate this procedure.
- If Not mnuSound.Checked Then
- Exit Sub
- End If
- ' If playback reached the end of the WAV file,
- ' rewind the WAV file and play again.
- If Tegomm1.Position = Tegomm1.Length Then
- Tegomm1.Command = "Prev"
- Tegomm1.Command = "Play"
- End If
- End Sub
- Private Sub Timer1_Timer()
- Static Bus
- Static BumpPosition
- ' If the program's window is currently minimized,
- ' exit this procedure.
- If Me.WindowState = 1 Then
- Exit Sub
- End If
- ' If the Bumpy Ride menu item is checked,
- ' create the illusion of a bumpy ride.
- If mnuBumpyRide.Checked Then
- If BumpPosition = 0 Then
- sprBus.SpriteTop = sprBus.SpriteTop - 5
- BumpPosition = 1
- Else
- sprBus.SpriteTop = sprBus.SpriteTop + 5
- BumpPosition = 0
- End If
- End If
- ' Draw the background sprite inside WinG.
- sprBack.SpriteHandle = gBack
- sprBack.DrawSprite
- ' Draw the sprBus sprite inside WinG.
- If Bus = 0 Then sprBus.SpriteHandle = gBus0
- If Bus = 1 Then sprBus.SpriteHandle = gBus1
- If Bus = 2 Then sprBus.SpriteHandle = gBus2
- If Bus = 3 Then sprBus.SpriteHandle = gBus3
- sprBus.DrawSprite
- ' Slam WinG into the screen.
- sprBack.SlamIt
- ' Increment the Bus static variable.
- Bus = Bus + 1
- If Bus = 4 Then Bus = 0
- ' Shift the background sprite to the left.
- sprBack.SpriteLeft = sprBack.SpriteLeft - 20
- If sprBack.SpriteLeft <= -100 Then
- sprBack.SpriteLeft = 0
- End If
- End Sub
-